package com.foo.LoadingData;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

public class LoadFile {
	public static String loadFile(byte[] fileDate,int startPos,int endPos)
	{
		try
		{
			Properties properties = new Properties();
			properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
			properties.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");			
			properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
			
			Context ctx = new InitialContext(properties);
			Object ref = ctx.lookup("DataLoader/remote");
			DataLoaderRemote loadData = (DataLoaderRemote) PortableRemoteObject.narrow(ref, DataLoaderRemote.class);
			return loadData.storeData(fileDate, startPos, endPos);
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
			return null;
		}
	}
}
